/*    */ package com.zimbra.cs.pop3;
/*    */ 
/*    */ import com.google.common.base.Charsets;
/*    */ import com.google.common.collect.ImmutableMap;
/*    */ import com.zimbra.common.localconfig.KnownKey;
/*    */ import com.zimbra.common.localconfig.LC;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.stats.RealtimeStatsCallback;
/*    */ import com.zimbra.cs.server.NioConnection;
/*    */ import com.zimbra.cs.server.NioHandler;
/*    */ import com.zimbra.cs.server.NioServer;
/*    */ import com.zimbra.cs.server.ServerConfig;
/*    */ import com.zimbra.cs.server.ServerThrottle;
/*    */ import com.zimbra.cs.stats.ZimbraPerf;
/*    */ import java.util.Map;
/*    */ import org.apache.mina.core.session.IoSession;
/*    */ import org.apache.mina.filter.codec.ProtocolCodecFactory;
/*    */ import org.apache.mina.filter.codec.ProtocolDecoder;
/*    */ import org.apache.mina.filter.codec.ProtocolEncoder;
/*    */ import org.apache.mina.filter.codec.textline.LineDelimiter;
/*    */ import org.apache.mina.filter.codec.textline.TextLineDecoder;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public final class NioPop3Server
/*    */   extends NioServer
/*    */   implements Pop3Server, RealtimeStatsCallback
/*    */ {
/* 41 */   private static final ProtocolDecoder DECODER = new TextLineDecoder(Charsets.ISO_8859_1, LineDelimiter.AUTO);
/*    */   
/*    */   public NioPop3Server(Pop3Config config) throws ServiceException {
/* 44 */     super(config);
/* 45 */     registerMBean(getName());
/* 46 */     ZimbraPerf.addStatsCallback(this);
/* 47 */     ServerThrottle.configureThrottle(config.getProtocol(), LC.pop3_throttle_ip_limit.intValue(), LC.pop3_throttle_acct_limit.intValue(), getThrottleSafeHosts(), getThrottleWhitelist());
/*    */   }
/*    */   
/*    */   public String getName()
/*    */   {
/* 52 */     return this.config.isSslEnabled() ? "Pop3SSLServer" : "Pop3Server";
/*    */   }
/*    */   
/*    */   public NioHandler createHandler(NioConnection conn)
/*    */   {
/* 57 */     return new NioPop3Handler(this, conn);
/*    */   }
/*    */   
/*    */   protected ProtocolCodecFactory getProtocolCodecFactory()
/*    */   {
/* 62 */     new ProtocolCodecFactory()
/*    */     {
/*    */       public ProtocolEncoder getEncoder(IoSession session) throws Exception {
/* 65 */         return NioPop3Server.DEFAULT_ENCODER;
/*    */       }
/*    */       
/*    */       public ProtocolDecoder getDecoder(IoSession session)
/*    */       {
/* 70 */         return NioPop3Server.DECODER;
/*    */       }
/*    */     };
/*    */   }
/*    */   
/*    */   public Pop3Config getConfig()
/*    */   {
/* 77 */     return (Pop3Config)super.getConfig();
/*    */   }
/*    */   
/*    */   public Map<String, Object> getStatData()
/*    */   {
/* 82 */     String connStatName = getConfig().isSslEnabled() ? "pop_ssl_conn" : "pop_conn";
/* 83 */     String threadStatName = getConfig().isSslEnabled() ? "pop_ssl_threads" : "pop_threads";
/* 84 */     return ImmutableMap.of(connStatName, Integer.valueOf(getNumConnections()), threadStatName, Integer.valueOf(getNumThreads()));
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/pop3/NioPop3Server.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */